-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Daniela Sanchez - Paper #1
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work Daniela, you hit the learning goals here. Take a look at my feedback on time/space complexity and top_k_frequent_elements. Let me know if you have questions.
Just FYI you submitted this in the Ruby section. That's why the tests failed.
// Time Complexity: O(n^2) | ||
// Space Complexity: O(n) | ||
function grouped_anagrams(strings) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 However this is not an O(n^2) solution. Instead it's O(n), if the words are limited in length (like to English words). If the words are not limited it's O(n * m log m) due to sorting.
// Time Complexity: O(n^2) | ||
// Space Complexity: O(n) | ||
function top_k_frequent_elements(list, k) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 But the time complexity is O(n) time complexity is O(n * k * m) where n is the number of elements and k the number of most frequent elements and m the size of the most frequent element. It can be written more efficiently, but this is an ok solution.
// Time Complexity: O(n^2) | ||
// Space Complexity: O(n) | ||
function valid_sudoku(table) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One note. Because Sudoku boards never change in size, scale isn't an issue!
if (highest_freq in counting_hash) { | ||
for (let i = 0; i < counting_hash[highest_freq].length; i++) { | ||
if (output.length === k) { | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of counting down highest_freq each time, you simply find the largest value in the object and then remove that key-value pair. That might speed things up.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions